<?php
namespace PsiFramework\Applications\AlloMediaUser\Classes\Actions;

import("Applications.AlloMediaUser.Classes.Actions.ShopAction");
import("Classes.Util.HTTP.AuthenticationManager");
import("Classes.Factory.DAOFactory");

use \PsiFramework\Applications\AlloMediaUser\Classes\Actions\ShopAction;
use \PsiFramework\Classes\Util\HTTP\AuthenticationManager;
use \PsiFramework\Classes\Util\Parameters\Action\ActionParameters;
use \PsiFramework\Classes\Factory\DAOFactory;

/**
 * PsiFramework
 * Php Simple Framework
 *
 * @author Rémi San
 * @version beta
 */

/**
 * Classe d'action de l'index
 *
 * @package Actions.Pages
 */
class AlloMediaUserSaveBilling extends ShopAction
{

    public function __construct(ActionParameters $actionParameters)
    {
        parent::__construct($actionParameters);
    }

    /**
     * The main function of the method which is called every time
     * an action is created by the front controller.
     *
     */
    public function execute()
    {
        parent::execute();
            
        $user = $this->_user;
        $userDao = DAOFactory::getDAO('User');
            
        if (!is_null($user)) {
            $user->setFirstName($this->_request->getParameter('firstName'));
            $user->setSurName($this->_request->getParameter('lastName'));
            
            $user->setAddress($this->_request->getParameter('address'));
            $user->setZipCode($this->_request->getParameter('zipCode'));
            $user->setCityName($this->_request->getParameter('cityName'));
            
            $ok = $userDao->save($user);

            $this->_response->setAttribute("status", ($ok)?'ok':'nok');

        }
        $this->findForward('success');
    }
}
